layui.config({
	base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage,
		layedit = layui.layedit,
		laydate = layui.laydate,
		$ = layui.jquery;

 	var systemParameter;
 	var editIndex = layedit.build('news_content');
 	//加载默认数据
 	var orgId = window.sessionStorage.getItem("organizeId");;
	var data = {
		orgId:orgId,
		memberNum:window.sessionStorage.getItem("memberNumEditId")
	}
	getUser(data);
 	

 	//填充数据方法
 	function fillData(data){
 		$(".memberNum").val(data.memberNum);  
 		$(".name").val(data.name); //当前版本
		$(".department").val(data.department.name);        //开发作者
		$(".profession").val(data.profession.name);    //网站首页
		$(".mobile").val(data.mobiles[0]);        //服务器环境
		$(".wechat").val(data.weChat);    //数据库版本
		$(".tel").val(data.tel);  //最大上传限制
		$(".email").val(data.email);//当前用户权限
		$(".birthday").val(data.newBirthday);      //模版名称
		$(".site").val(data.site);	//站点描述
		$("#news_content").val(data.introduce);      //版权信息

		$('[name="otype"]').attr("disabled", "disabled");
//		$("input[name=otype][value=0]").attr("checked", true); //设置当前性别选中项
//		$("input[name=otype][value=" + data.type + "]").attr("checked", true); //设置当前性别选中项
		form.render('radio');
		for (var i = 1; i < data.mobiles.length; i++) {
                    var str = '<div class="layui-form-item"><label class="layui-form-label">手机</label><div class="layui-input-block">' +
                        '      <input type="text" class="layui-input wechat" value= ' + data.mobiles[i] + ' disabled="disabled">'
                        ' </div></div>'
                    $("#mobileTop").before(str);
        }
		
		
 	}
 
function getUser(data) {
	var index = layer.load(1, {
		shade: [0.1, '#fff']
	}); //0.1透明度的白色背景
	//top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});

	console.log('step into registerSubmit()')
	$.ajax({
		url: $.httpRootPath() + "/api/web/member/i/" + data.orgId + "/" + data.memberNum,
		type: "get",
		dataType: "json",
		data: data,
		success: function(data) {
			if(data.code == "00") {
				fillData(data.data);
			} else {
				layer.msg(data.msg);
				return;
			}
		},
		error: function() {
			layer.alert('加载失败', {
				icon: 6,
				title: '友情提示'
			});
		},
		complete: function() {
			layer.close(index);
		}
	})

}
})
